package com.yijiajiao.finance.controller;

import com.yijiajiao.finance.bean.AliAccount;
import com.yijiajiao.finance.bean.ResultBean;
import com.yijiajiao.finance.service.AliAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 用户绑定支付宝账号相关操作
 *
 * @author zhaoming
 * @since 2017-08-10
 */

@RestController
@RequestMapping("/aliAccount")
public class AliAccountController {

    @Autowired
    private AliAccountService aliAccountService;

    /**
     * 绑定支付宝账号
     * 2017/8/10 11:28
     */
    @PostMapping("/bind")
    public ResultBean bindAccount( @RequestBody AliAccount aliAccount) {

        return aliAccountService.addAccount(aliAccount);

    }

    /**
     * 通过openId查询绑定的支付宝账号信息
     * 2017/8/10 11:44
     */ 
    @GetMapping("/aliAccountInfo")
    public ResultBean aliAccountInfoByOpenId(@RequestParam String openId){

        return aliAccountService.queryByOpenId( openId );
    }

    /**
     *  解绑支付宝账号
     *  2017/8/10 11:44
     */
    @DeleteMapping("/cancelBind")
    public ResultBean cancelBind( @RequestParam String openId){

        return aliAccountService.delByOpenId( openId );

    }

}
